From: Øyvind Kolås Date: Sun, 2 Dec 2018 22:49:21 +0000 (+0100) Subject: add a format for muxing cmyk u8 in and out of rgba u8 buffers X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~12^2~24 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=8a0aafc5f2007d9c506fd38f629f621ea50dcc75;p=babl.git add a format for muxing cmyk u8 in and out of rgba u8 buffers --- diff --git a/extensions/naive-CMYK.c b/extensions/naive-CMYK.c index a8a874a..1e1c905 100644 --- a/extensions/naive-CMYK.c +++ b/extensions/naive-CMYK.c @@ -28,10 +28,67 @@ int init (void); +/* implement a hacky way to do cmyk with cairo */ +/* CMYKA */ +/* CMKA */ +/* CKYA */ + + int init (void) { - /* do nothing, drop this whole file after a couple of releases */ + babl_format_new ("name", "ckyA u16", + babl_model ("cmykA"), + babl_type ("u16"), + babl_component ("cyan"), + babl_component ("key"), + babl_component ("yellow"), + babl_component ("A"), + NULL); + babl_format_new ("name", "cmkA u16", + babl_model ("cmykA"), + babl_type ("u16"), + babl_component ("cyan"), + babl_component ("magenta"), + babl_component ("key"), + babl_component ("A"), + NULL); + + babl_format_new ("name", "camakaA u8", + babl_model ("camayakaA"), + babl_type ("u8"), + babl_component ("ka"), + babl_component ("ma"), + babl_component ("ca"), + babl_component ("A"), + NULL); + babl_format_new ("name", "cakayaA u8", + babl_model ("camayakaA"), + babl_type ("u8"), + babl_component ("ya"), + babl_component ("ka"), + babl_component ("ca"), + babl_component ("A"), + NULL); + babl_format_new ("name", "camaPadkaA u8", + babl_model ("camayakaA"), + babl_type ("u8"), + babl_component ("ca"), + babl_component ("ma"), + babl_component ("PAD"), + babl_component ("ka"), + babl_component ("A"), + NULL); + babl_format_new ("name", "caPadyakaA u8", + babl_model ("camayakaA"), + babl_type ("u8"), + babl_component ("ca"), + babl_component ("PAD"), + babl_component ("ya"), + babl_component ("ka"), + babl_component ("A"), + NULL); + return 0; } diff --git a/tests/Makefile.am b/tests/Makefile.am index e48b1dd..8c5abb7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -5,6 +5,7 @@ CONCURRENCY_STRESS_TESTS = \ endif C_TESTS = \ + cairo_cmyk_hack \ grayscale_to_rgb \ chromaticities \ rgb_to_bgr \ diff --git a/tests/cairo_cmyk_hack.c b/tests/cairo_cmyk_hack.c new file mode 100644 index 0000000..3996402 --- /dev/null +++ b/tests/cairo_cmyk_hack.c @@ -0,0 +1,79 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2005, Øyvind KolÃ¥s. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * . + */ + +#include +#include +#include + +#define PIXELS 6 +#define TOLERANCE 0 + +unsigned char source_buf [PIXELS * 5] = +{ 0, 0, 0, 22, 33, + 127, 127, 127, 12, 33, + 255, 225, 255, 33, 33, + 255, 0.0, 0.0, 4, 33, + 0.0, 255, 0.0, 122,33, + 0.0, 0.0, 255, 222,33}; + +unsigned char cmk_buf [PIXELS * 4]; +unsigned char cky_buf [PIXELS * 4]; +unsigned char dest_buf [PIXELS * 5]; + +static int +test (void) +{ + int i; + int OK = 1; + + babl_process (babl_fish ("camayakaA u8", "camakaA u8"), + source_buf, cmk_buf, + PIXELS); + babl_process (babl_fish ("camayakaA u8", "cakayaA u8"), + source_buf, cky_buf, + PIXELS); + babl_process (babl_fish ("cakayaA u8", "camayakaA u8"), + cky_buf, dest_buf, + PIXELS); + babl_process (babl_fish ("camakaA u8", "camayakaA u8"), + cmk_buf, dest_buf, + PIXELS); + + for (i = 0; i < PIXELS * 5; i++) + { + if (fabs (dest_buf[i] - source_buf[i]) > TOLERANCE) + { + fprintf (stderr, "%i is wrong\n", i); + OK = 0; + } + } + if (!OK) + return -1; + return 0; +} + +int +main (int argc, + char **argv) +{ + babl_init (); + if (test ()) + return -1; + babl_exit (); + return 0; +}